#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QListWidgetItem>
#include <QStringList>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    //单选按钮设置默认选中
    ui->radioButton_Man->setChecked(true);

    //点击女单选按钮，打印输出
    connect(ui->radioButton_Women, &QRadioButton::clicked, this, [=](){
        qDebug()<<"选择了女的";
    });

    //复选按钮 点击环境好之后监听
    connect(ui->chk_chifan_hjh, &QCheckBox::stateChanged, this, [=](int state){
        qDebug()<<"点击好环境好, state=" << state;
    });

    //listWidget
//    QListWidgetItem * item1 = new QListWidgetItem("锄禾日当午");
//    //设置居中
//    item1->setTextAlignment(Qt::AlignHCenter);
//    QListWidgetItem * item2 = new QListWidgetItem("汗滴禾下土");
//    QListWidgetItem * item3 = new QListWidgetItem("谁知盘中餐");
//    QListWidgetItem * item4 = new QListWidgetItem("粒粒皆辛苦");

    //ui->listWidget->addItem(item1);
    //ui->listWidget->addItem(item2);
    //ui->listWidget->addItem(item3);
    //ui->listWidget->addItem(item4);

    //QStringList  QList<QString> list<string>
    QStringList stringList;
    stringList << "锄禾日当午" << "汗滴禾下土" << "谁知盘中餐" << "粒粒皆辛苦";

    ui->listWidget->addItems(stringList);
}

Widget::~Widget()
{
    delete ui;
}
